package Entity;

import java.sql.ResultSet;

import Control.MySQLController;

public class NeedyResident_ActivateUser {
	
	private static String nric;
	private static String name;
	private static String email;
	private static String contactNo;
	private static String address;
	private static String password;

	public static String getPassword() {
		return password;
	}

	public static void setPassword(String password) {
		NeedyResident_ActivateUser.password = password;
	}

	public static String getNric() {
		return nric;
	}

	public void setNric(String nric) {
		NeedyResident_ActivateUser.nric = nric;
	}

	public static String getName() {
		return name;
	}

	public void setName(String name) {
		NeedyResident_ActivateUser.name = name;
	}

	public static String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		NeedyResident_ActivateUser.email = email;
	}

	public static String getContactNo() {
		return contactNo;
	}

	public void setContactNo(String contactNo) {
		NeedyResident_ActivateUser.contactNo = contactNo;
	}

	public static String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		NeedyResident_ActivateUser.address = address;
	}

	public NeedyResident_ActivateUser(String nric, String name, String email, String contactNo, String address, String password) {
		super();
		NeedyResident_ActivateUser.nric = nric;
		NeedyResident_ActivateUser.name = name;
		NeedyResident_ActivateUser.email = email;
		NeedyResident_ActivateUser.contactNo = contactNo;
		NeedyResident_ActivateUser.address = address;
		NeedyResident_ActivateUser.password = password;
	}
	
	public NeedyResident_ActivateUser(){
		
	}
	
	public boolean ActivateUser(){
		boolean success = false;
		
		MySQLController db = new MySQLController();
		db.getConnection();
		String sql = "UPDATE ooadpj.user";
		sql += " Set user_status_code = 'A'";
		sql += " WHERE nric = '" + getNric()+"'";
		if(db.updateRequest(sql)==1)
			success = true;
		db.terminate();
		
		return success;

	}
	public boolean GetUserInfo(){
		boolean success = false;
		
		ResultSet rs = null;
		MySQLController db = new MySQLController();
		db.getConnection();
		String sql = "SELECT * FROM ooadpj.user WHERE nric = '" + getNric() + "'";
		rs = db.readRequest(sql);
		try{
			while(rs.next()){
				setNric(rs.getString("nric"));
				setName(rs.getString("name"));
				setEmail(rs.getString("email"));
				setAddress(rs.getString("address"));
				setContactNo(rs.getString("contact_no"));
				setPassword(rs.getString("password"));
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}
		finally{
			db.terminate();
		}
		
		return success;
	}

}
